<?php

Solar::loadClass('Solar_Base', true);

abstract class Domain51_Model_Meta_Abstract extends Solar_Base 
{ 
    protected $_table_name = '';
    public function __construct($config = null)
    {
        $this->_init($config);
    }
    
    protected function _init($config)
    {
        if (empty($config['table_name'])) {
            preg_match('/_([A-Z0-9]+)_Model_Meta/i', get_class($this), $matches);
            $config['table_name'] = strtolower($matches[1]);
        }
        $this->_table_name = $config['table_name'];
        
        $sql = Solar::factory('Solar_Sql');
        $tableInfo = $sql->describeTable($this->_table_name);
        $this->_columns = array_keys($tableInfo);
    }
    
    public function __get($key)
    {
        $realKey = "_$key";
        return $this->$realKey;
    }
} 